import 'package:dio/dio.dart';
import 'package:flutter/material.dart';

class JsonReq extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'todolist',
      home: new Scaffold(
          appBar: new AppBar(
            title: new Text('todo list'),
          ),
          body: new Center(
            child: new RaisedButton(
              onPressed: getJson,
              child: new Text('get json'),
            ),
          )),
    );
  }
  
  void getJson() async{
    try{
      Response resp = await Dio().get('https://jsonplaceholder.typicode.com/posts/1');
      print(resp);
    }catch(e){
      
    }
  }
}
